/*
    This file is part of the AmaurotMS MapleStory Server, commands OdinMS-based
    Copyleft (L) 2016 - 2019 RonanLana

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation version 3 as published by
    the Free Software Foundation. You may not use, modify or distribute
    this program under any other version of the GNU Affero General Public
    License.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
   @Author: MizukiandEna - Refactored command content into modules
*/
package org.gms.client.command.commands.gm0;

import org.gms.client.Character;
import org.gms.client.Client;
import org.gms.client.command.Command;

public class SetSwordCommand extends Command {
    {
        setDescription("变成剑姿态。当队伍中有队友是盾姿态时，将自己受的伤害转移。 ");
    }
    @Override
    public void execute(Client c, String[] params) {
        Character player = c.getPlayer();
        if (params.length > 0) {
            int x = Integer.parseInt(params[0]);
            if((x>4)&&(x<100)){

                player.getAbstractPlayerInteraction().saveOrUpdateCharacterExtendValue("剑盾姿态","sword");
                player.getAbstractPlayerInteraction().saveOrUpdateCharacterExtendValue("剑盾数值",params[0]);
                player.yellowMessage("剑姿态Sword已开启。您现在开始依靠自己的队友。您受的伤为原先的"+x+"%，您的盾姿态队友将分摊您原本承受的"+(200-2*x)+"%伤害");
            }else{
                player.yellowMessage("使用方式@sword [整数x]， x必须在5-99之间。当队伍中有队友是盾姿态时，自己只承受x/100的伤害，而所有盾姿态队友将平摊(200-2*x)/100的伤害。");
            }
        }else{
            player.yellowMessage("使用方式@sword [整数x]， x必须在0-99之间。当队伍中有队友是盾姿态时，自己只承受x/100的伤害，而所有盾姿态队友将平摊(200-2*x)/100的伤害。");
        }
    }
}